package ch3;

/**
 * Created by wyao on 17-3-6.
 * 避免对boolean判断
 */
public class C3_3 {
    static boolean method1(String s) {
        return s.endsWith("a") == true;
    }

    static boolean method2(String s) {
        return s.endsWith("a");
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000000000; i++) {
            C3_3.method1("aaa");
        }
        System.out.println(System.currentTimeMillis() - start);

        start = System.currentTimeMillis();
        for (int i = 0; i < 1000000000; i++) {
            C3_3.method2("aaa");
        }
        System.out.println(System.currentTimeMillis() - start);
    }
}
